<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/css/bootstrap.min.css" />
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/css/bootstrap-theme.min.css" />
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/themes/bootstrap/easyui.css" />
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/themes/icon.css" />

<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/jquery.min.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/jquery.easyui.min.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/easyui-lang-zh_CN.js"></script>
</head>
<script type="text/javascript">
	$(function(){
		$("#orderMsg").datagrid({
			url: '${pageContext.request.contextPath}/cShowCurrentOrderAction',
			title: '订单列表',
			striped:true,
			nowrap: false,
			columns:[[    
					{field:'checked',checkbox:true,width:100},
			        {field:'oid',title:'订单id',width:100,hidden:true}, 
			        {field:'sid',title:'商家id',width:100,hidden:true},
			        {field:'sname',title:'餐厅名字',width:100},
			        {field:'odishies',title:'订单内容',width:580},
			        {field:'osumprices',title:'订单价格',width:60}, 
			        {field:'ocreatetime',title:'订单创建时间',width:100},
			        {field:'sphone',title:'餐厅电话',width:100},
			        {field:'state',title:'订单状态',width:100},
			]],
			//是否显示分页
			pagination:true,
			rownumbers : true,
			toolbar : [{
				iconCls : 'icon-cut',
				text : '撤销订单',
				handler : function() {
					var orders =	$("#orderMsg").datagrid('getSelections');
					if(orders.length!=1){
						$.messager.confirm('提示','请选择一条数据',function(){    
							$("#orderMsg").datagrid('clearSelections');
						}); 
					}else{
						window.parent.$.messager.confirm('提示','确定要撤销吗',function(r){    
						    if (r){    
								$.ajax({
									type: 'post',
									url: '${pageContext.request.contextPath}/revokeCurrentOrderAction',
									data: {"oid": orders[0].oid,"odishies":orders[0].odishies,"sid": orders[0].sid},
									dataType: 'text',
									success: function(data){
										if(data=="1"){
											$('#orderMsg').datagrid('reload');
											$.messager.show({
												title:'提示',
												msg:'撤销成功',
												timeout:2000,
												showType:'slide'
											});
										}else{
											$.messager.show({
												title:'提示',
												msg:'撤销失败',
												timeout:2000,
												showType:'slide'
											});
										}
									}
								});    
						    }    
						});
						
					}
				}
			}],
		});
		
	});

</script>
<body class="container-fluid">
	<table id="orderMsg"></table>

</body>
</html>